/**
 * 
 */
package Connexion;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import Structure.Film;

/**
 * @author tangi
 * 
 */
public class ChargeurdeDonnees {

	private mysqlConnector connector;
	private ArrayList<String> listeFilms;
	private String requete = "";
	private ArrayList<String> listeRecherche;

	/**
	 * 
	 */
	public ChargeurdeDonnees() {

		listeFilms = new ArrayList<String>();
		listeRecherche = new ArrayList<String>();
		connector = new mysqlConnector();

	}

	public ArrayList<String> chargerEnListe() {
//		connector.connection();
//		ResultSet result = connector.requeteSelect(requete);
		listeFilms.clear();
		
//
//		try {
//			while (result.next()) {
//				String str = result.getString("nameFilm");
//				listeFilms.add(str);
//			}
//		} catch (SQLException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}// end while loop

		return listeFilms;
	}

	public ArrayList<String> chargementRecherche(String requete){
//		connector.connection();
//		ResultSet result = connector.requeteSelect(requete);
		listeRecherche.clear();

//		try {
//			while (result.next()) {
//				String str = result.getString("nameFilm");
//				listeRecherche.add(str);
//			}
//		} catch (SQLException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}// end while loop

		return listeRecherche;
	}
	
	public Film ChargerFilm(String name) {
		name = name.replaceAll("'", "''");
		requete = "Select * from Film where nameFilm='" + name + "'";
//		ResultSet film = connector.requeteSelect(requete);

//		try {
//			film.first();
//			return new Film(film.getString("nameFilm"),
//					film.getInt("note") - 1, film.getString("Synopsis"), film.getInt("genre"), film.getInt("year"));
//			
//
//		} catch (SQLException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
	return null;

	}

	public mysqlConnector getConnector() {
		return connector;
	}
}
